package com.kuaimacode.kframework.api.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kuaimacode.kframework.mybatis.mapper.user.UserMapRoleMapper;
import com.kuaimacode.kframework.mybatis.mapper.user.UserRoleMapper;
import com.kuaimacode.kframework.mybatis.models.user.UserMapRole;
import com.kuaimacode.kframework.mybatis.models.user.UserRole;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Slf4j
public class UserMapRoleService extends ServiceImpl<UserMapRoleMapper,UserMapRole> {

    @Transactional
    public boolean grantRole(String userId,String[] roleIds){
        try {
            baseMapper.grant(userId,roleIds);
        }catch (Exception ex){
            log.error("分配角色异常",ex);
            return false;
        }
        return true;
    }
}
